package o;

import com.huawei.appmarket.service.exposure.bean.ExposureBean;
import com.huawei.appmarket.service.exposure.bean.ExposureDetail;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;

public class dyg {
    private static final dyg ˊ = new dyg();
    private ReentrantLock ʼ = new ReentrantLock();
    private volatile List<ExposureDetail> ˋ = new ArrayList();
    private volatile List<ExposureDetail> ˎ = new ArrayList();
    private volatile List<ExposureDetail> ˏ = new ArrayList();
    private volatile List<ExposureDetail> ॱ = new ArrayList();

    private dyg() {
    }

    public static dyg ॱ() {
        return ˊ;
    }

    public String ॱ(int i) {
        return esg.ˋ().ˋ(i);
    }

    private List<ExposureDetail> ˊ(int i) {
        if (i == ccz.ॱ()) {
            return this.ˎ;
        }
        if (i == 18) {
            return this.ˋ;
        }
        if (i == 17) {
            return this.ॱ;
        }
        if (i == 1) {
            return this.ˏ;
        }
        return this.ˎ;
    }

    public void ˎ(ExposureDetail exposureDetail, int i) {
        this.ʼ.lock();
        try {
            if (ˊ(i).size() < 10000) {
                ˊ(i).add(exposureDetail);
            }
            this.ʼ.unlock();
        } catch (Throwable th) {
            this.ʼ.unlock();
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void ˎ(java.util.List<com.huawei.appmarket.service.exposure.bean.ExposureDetail> r5, int r6) {
        /*
        r4 = this;
        r0 = r4.ʼ;
        r0.lock();
        r0 = r4.ˊ(r6);	 Catch:{ ArrayIndexOutOfBoundsException -> 0x001e }
        if (r0 == 0) goto L_0x0018;
    L_0x000b:
        if (r5 == 0) goto L_0x0018;
    L_0x000d:
        r1 = r0.size();	 Catch:{ ArrayIndexOutOfBoundsException -> 0x001e }
        r2 = 10000; // 0x2710 float:1.4013E-41 double:4.9407E-320;
        if (r1 >= r2) goto L_0x0018;
    L_0x0015:
        r0.addAll(r5);	 Catch:{ ArrayIndexOutOfBoundsException -> 0x001e }
    L_0x0018:
        r0 = r4.ʼ;
        r0.unlock();
    L_0x001d:
        return;
    L_0x001e:
        r0 = move-exception;
        r1 = "ExposureDataProvider";
        r2 = new java.lang.StringBuilder;	 Catch:{ all -> 0x0041 }
        r2.<init>();	 Catch:{ all -> 0x0041 }
        r3 = "insertDetail error:";
        r2 = r2.append(r3);	 Catch:{ all -> 0x0041 }
        r0 = r0.toString();	 Catch:{ all -> 0x0041 }
        r0 = r2.append(r0);	 Catch:{ all -> 0x0041 }
        r0 = r0.toString();	 Catch:{ all -> 0x0041 }
        o.dna.ˋ(r1, r0);	 Catch:{ all -> 0x0041 }
        r0 = r4.ʼ;
        r0.unlock();
        goto L_0x001d;
    L_0x0041:
        r0 = move-exception;
        r1 = r4.ʼ;
        r1.unlock();
        throw r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.dyg.ˎ(java.util.List, int):void");
    }

    public boolean ˋ(int i) {
        return ˏ(i) >= 20;
    }

    public int ˏ(int i) {
        return ˊ(i).size();
    }

    public String ˊ(List<ExposureDetail> list, int i) {
        if (CollectCheck.isEmpty((List) list)) {
            return "";
        }
        ExposureBean exposureBean = new ExposureBean();
        exposureBean.ˊ(ॱ(i));
        exposureBean.ˎ(list);
        try {
            return exposureBean.toJson();
        } catch (IllegalAccessException e) {
            Logger.ˋ("ExposureDataProvider", "getExposureJson error:" + e.toString());
            return "";
        }
    }

    public List<ExposureDetail> ˎ(int i) {
        this.ʼ.lock();
        try {
            List ˊ = ˊ(i);
            if (CollectCheck.isEmpty(ˊ)) {
                return null;
            }
            List<ExposureDetail> arrayList;
            if (ˊ.size() > 50) {
                arrayList = new ArrayList(ˊ.subList(0, 50));
                ˊ.removeAll(arrayList);
            } else {
                arrayList = new ArrayList(ˊ);
                ˊ.clear();
            }
            this.ʼ.unlock();
            return arrayList;
        } finally {
            this.ʼ.unlock();
        }
    }
}
